rm(list=ls())

library(foreign)
library(ggplot2) #for plotting
library(rdrobust) 

#setwd("")

nofe <- read.dta("tired1000.dta")
fe <- read.dta("tired1000_fe.dta")

plot1<-ggplot(nofe, aes(x=b_easter_tired_fixed_2)) + 
  geom_histogram(data=nofe, colour="black") +
  theme_bw() +
  labs(x="Placebo Effect Sizes", y="Count", title="") +
  geom_vline(xintercept = -.0342907, colour="red", linetype = "longdash") +
  scale_x_continuous(limits = c(-0.05, 0.05))
plot1
ggsave(plot1, file="permutation_nofe.pdf", width=6, height=6, scale=2)


plot1<-ggplot(fe, aes(x=b_easter_tired_fixed_2)) + 
  geom_histogram(data=fe, colour="black") +
  theme_bw() +
  labs(x="Placebo Effect Sizes", y="Count", title="") +
  geom_vline(xintercept = -.0137868, colour="red", linetype = "longdash") +
  scale_x_continuous(limits = c(-0.05, 0.05))
plot1
ggsave(plot1, file="permutation_fe.pdf", width=6, height=6, scale=2)

###### R plot
geo.turnout<- read.dta("geo_turnout.dta")
attach(geo.turnout)

pdf("rdplot.pdf")
rdplot<-rdplot(turnout_pop, running_long_fixed, c=0, p=4, ci=95, x.label="Distance to the Time Zone (Degrees Longitude)",
       y.label="Proportion Voting", title="", x.lim=c(-10, 10), y.lim=c(0.15, 0.6), col.lines="red", col.dots="grey85",
       cex.lab=1.3, cex.axis=1.5, lwd=2)
rdplot
dev.off()


